Skip to main content

Simulate Swap

Simulates a swap operation and returns the amount to be received for the swap.

query Simulate_swap($assetIn: String!, $amountIn: String!, $assetOut: String!, $minAmountOut: String!, $swaps: [String!]) {
router {
simulate_swap(asset_in: $assetIn, amount_in: $amountIn, asset_out: $assetOut, min_amount_out: $minAmountOut, swaps: $swaps) {
amount_out
asset_out
}
}
}

Example

curl --request POST \
--header 'content-type: application/json' \
--url 'https://testnet.api.euclidprotocol.com/graphql' \
--data '{"query":"query Simulate_swap($assetIn: String!, $amountIn: String!, $assetOut: String!, $minAmountOut: String!, $swaps: [String!]) {\n router {\n simulate_swap(asset_in: $assetIn, amount_in: $amountIn, asset_out: $assetOut, min_amount_out: $minAmountOut, swaps: $swaps) {\n amount_out\n asset_out\n }\n }\n}","variables":{"assetIn":"euclid","amountIn":"1000","assetOut":"nibi","minAmountOut":"1","swaps":["euclid","nibi"]}}'

Open in Playground

Arguments

NameTypeDescription
assetInString!The identifier of the input asset.
amountInString!The amount of the input asset to swap.
assetOutString!The identifier of the output asset.
minAmountOutString!The minimum amount of the output asset expected from the swap.
swaps[String!]The list of swaps to execute for reaching the output asset.

Return Fields

FieldTypeDescription
amount_outStringThe amount of the output asset received from the swap.
asset_outStringThe identifier of the output asset.